home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Rice_CMS / gopher24 / gopcli.$exec < prev    next >
Encoding:
Text File  |  1993-01-25  |  19.5 KB  |  247 lines

  1. /*                                                                      00010000
  2.  *        Name: GOPCLI EXEC                                             00020000
  3.  *              VM TCP/IP Network GOPHER Client                         00030000
  4.  *      Author: Rick Troth, Rice University, Information Systems        00040000
  5.  *              Major thanks to Arty Ecock for the wonderful RXSOCKET.  00050000
  6.  *              Thanks to Serge Goldstein for help with many things.    00060000
  7.  *        Date: 1992-Dec-23                                             00070000
  8.  */                                                                     00080000
  9.                                                                         00090000
  10. /*                                                                      00100000
  11.  *      Copyright 1992 Richard M. Troth.   This software was developed  00110000
  12.  *      with resources provided by Rice University and is intended      00120000
  13.  *      to serve Rice's user community.   Rice has benefitted greatly   00130000
  14.  *      from the free distribution of software,  therefore distribution 00140000
  15.  *      of unmodified copies of this material is not restricted.        00150000
  16.  *      You may change your own copy as needed.   Neither Rice          00160000
  17.  *      University nor any of its employees or students shall be held   00170000
  18.  *      liable for damages resulting from the use of this software.     00180000
  19.  */                                                                     00190000
  20.                                                                         00200000
  21. /*                                                                      00210000
  22.  *       Calls:                                                         00220000
  23.  *              RXSOCKET MODULE   -- for TCP/IP network services        00230000
  24.  *              PIPE     MODULE   -- for various I/O functions          00240000
  25.  *              GLOBALV           -- for temp and perm global vars      00250000
  26.  *              XMITMSG           -- for all message output             00260000
  27.  *              VM TCP/IP, V2 or later (through RXSOCKET)               00270000
  28.  *                                                                      00280000
  29.  *              GOPCLINI EXEC     -- to initialize many things          00290000
  30.  *              GOPCLITM REXX     -- to fetch the first item (a menu)   00300000
  31.  *              GOPCLIMB REXX     -- to display a menu (from bookmarks) 00310000
  32.  *                     both of which call other gems                    00320000
  33.  *                                                                      00330000
  34.  *    perm GVs:                                                         00340000
  35.  *        HOST  -  the host to connect to for the root menu             00350000
  36.  *        PORT  -  the port on that host for Gopher service             00360000
  37.  *        PATH  -  the path to the initial menu                         00370000
  38.  *        NAME  -  the name of the initial menu                         00380000
  39.  *      TELNET  -  the name of the CMS TELNET command  (user preference)00390000
  40.  *      TN3270  -  the name of the command for 3270 telnet connections  00400000
  41.  *      VIEWER  -  the CMS command (XEDIT or BROWSE) used to view a file00410000
  42.  *   BOOKMARK.  -  prefix for all bookmark variables,  where what       00420000
  43.  *                 follows the dot is the name of the bookmark          00430000
  44.  *                                                                      00440000
  45.  *    temp GVs:                                                         00450000
  46.  *        TUBE  -  the virtual address of a DIALed terminal (not cons)  00460000
  47.  *      GOPHER  -  the IUCV path name and translate table name          00470000
  48.  *      PROGID  -  program name                                         00480000
  49.  *        ITEM  -  a line of "gopher menu data" for the chosen item     00490000
  50.  *         ...                                                          00500000
  51.  */                                                                     00510000
  52.                                                                         00520000
  53. Trace "OFF"                                                             00530000
  54.                                                                         00540000
  55. Address "COMMAND"                                                       00550000
  56.                                                                         00560000
  57. 'SET LANGUAGE (ADD GOP USER'                                            00570000
  58. If rc ^= 0 Then Exit rc                                                 00580000
  59.                                                                         00590000
  60. 'STATE PIPE MODULE *'                                                   00600000
  61. If rc ^= 0 Then Do                                                      00610000
  62.     qrc = rc                                                            00620000
  63.     /*  "You must have CMS Pipelines to run CMS Gopher."  */            00630000
  64.     'XMITMSG 3 (APPLID GOP CALLER CLI ERRMSG'                           00640000
  65.     Exit qrc                                                            00650000
  66.     End  /*  If  ..  Do  */                                             00660000
  67.                                                                         00670000
  68. /*  Thanks to Nick LaFlamme for the linemode catcher.  */               00680000
  69. 'PIPE COMMAND QUERY DISPLAY'                                            00690000
  70. If rc ^= 0 Then Do                                                      00700000
  71.     qrc = rc                                                            00710000
  72.     'XMITMSG 523 (ERRMSG'       /*  "Typewriter mode"  */               00720000
  73.     /*  "CMS Gopher requires a full-screen terminal."  */               00730000
  74.     'XMITMSG 926 (APPLID GOP CALLER CLI ERRMSG'                         00740000
  75.     Exit qrc                                                            00750000
  76.     End  /*  If  ..  Do  */                                             00760000
  77.                                                                         00770000
  78. 'STATE RXSOCKET MODULE *'                                               00780000
  79. If rc ^= 0 Then Do                                                      00790000
  80.     qrc = rc                                                            00800000
  81.     /*  "You must have RXSOCKET to run CMS Gopher."  */                 00810000
  82.     'XMITMSG 1 (APPLID GOP CALLER CLI ERRMSG'                           00820000
  83.     Exit qrc                                                            00830000
  84.     End  /*  If  ..  Do  */                                             00840000
  85.                                                                         00850000
  86. 'STATE TCPIP DATA *'                                                    00860000
  87. If rc ^= 0 Then Do                                                      00870000
  88.     qrc = rc                                                            00880000
  89.     /*  "You must have VM TCP/IP V2 to run CMS Gopher."  */             00890000
  90.     'XMITMSG 2 (APPLID GOP CALLER CLI ERRMSG'                           00900000
  91.     Exit qrc                                                            00910000
  92.     End  /*  If  ..  Do  */                                             00920000
  93.                                                                         00930000
  94. Parse Arg host port path '(' options ')' .                              00940000
  95.                                                                         00950000
  96. If host = "" & options = "" Then 'GLOBALV SELECT GOPHER GET PATH NAME'  00960000
  97.                             Else name = ""                              00970000
  98.                                                                         00980000
  99. /* Initialize some variables */                                         00990000
  100. bookmark = ""                                                           01000000
  101. bkl  = 0                                                                01010000
  102. tube = "CONS"                                                           01020000
  103. quit = 0                                                                01030000
  104.                                                                         01040000
  105. /* process options, if any */                                           01050000
  106. Do While options ^= ""                                                  01060000
  107.     Parse Var options op options                                        01070000
  108.     Upper op                                                            01080000
  109.     Select  /*  op  */                                                  01090000
  110.         When    Abbrev("TOPIC",op,2)    | ,                             01100000
  111.                 Abbrev("PATH",op,1)     Then Do                         01110000
  112.                     path = options                                      01120000
  113.                     options = ""                                        01130000
  114.                     End  /*  When  ..  Do  */                           01140000
  115.         When    Abbrev("TUBE",op,2)     Then                            01150000
  116.                     Parse Var options tube options                      01160000
  117.         When    Abbrev("BOOKMARK",op,1) | ,                             01170000
  118.                 Abbrev("BKMARK",op,3)   Then                            01180000
  119.                     Parse Var options bookmark options                  01190000
  120.         When    Abbrev("BOOKLIST",op,5) | ,                             01200000
  121.                 Abbrev("BKLIST",op,3)   Then Do                         01210000
  122.                     bkl = 1                                             01220000
  123.                     End  /*  When  ..  Do  */                           01230000
  124.         When    Abbrev("TITLE",1)       Then Do                         01240000
  125.                     name = options                                      01250000
  126.                     options = ""                                        01260000
  127.                     End  /*  When  ..  Do  */                           01270000
  128.         Otherwise 'XMITMSG 3 OP (ERRMSG'                                01280000
  129.         End  /*  Select  op  */                                         01290000
  130.     End  /*  Do  While  */                                              01300000
  131.                                                                         01310000
  132. /*  initialize many GlobalVs,  including screen stem  */                01320000
  133. 'EXEC GOPCLINI' tube                                                    01330000
  134.                                                                         01340000
  135. /*  Now go display first menu or file or bookmark  */                   01350000
  136. Select                                                                  01360000
  137.     When    bkl         Then Call BOOKLIST                              01370000
  138.     When bookmark ^= "" Then Call BOOKMARK                              01380000
  139.     Otherwise                Call SHOWITEM                              01390000
  140.     End  /*  Select  */                                                 01400000
  141.                                                                         01410000
  142. /*  clear some work GlobalVs  */                                        01420000
  143. 'GLOBALV SELECT GOPHER SET PROGID'                                      01430000
  144. 'GLOBALV SELECT GOPHER SET GOPHER'                                      01440000
  145. 'GLOBALV SELECT GOPHER SET TUBE'                                        01450000
  146. 'GLOBALV SELECT GOPHER SET ITEM'                                        01460000
  147. 'GLOBALV SELECT GOPHER SET COMMAND QUIT'        /* no recursion here */ 01470000
  148.                                                                         01480000
  149. Exit                                                                    01490000
  150.                                                                         01500000
  151.                                                                         01510000
  152.                                                                         01520000
  153. /* ------------------------------------------------------------ SHOWITEM01530000
  154.  */                                                                     01540000
  155. SHOWITEM:                                                               01550000
  156.                                                                         01560000
  157. If host = "" Then 'GLOBALV SELECT GOPHER GET HOST'                      01570000
  158. If host = "" Then host = "gopher.tc.umn.edu"                            01580000
  159.                                                                         01590000
  160. If port = "" Then 'GLOBALV SELECT GOPHER GET PORT'                      01600000
  161. If port = "" Then port = 70                                             01610000
  162.                                                                         01620000
  163. If name = "" Then Do                                                    01630000
  164.     Parse Value Reverse(path) With name '/' .                           01640000
  165.     name = Reverse(name)                                                01650000
  166.     End  /*  If  ..  Do  */                                             01660000
  167.                                                                         01670000
  168. If name = "" Then Do                                                    01680000
  169.     'PIPE COMMAND XMITMSG 4 (APPLID GOP CALLER CLI | VAR NAME'          01690000
  170.     Parse Var name . name                                               01700000
  171.     End  /*  If  ..  Do  */                                             01710000
  172.                                                                         01720000
  173. type = Left(path,1)                                                     01730000
  174. If type = '/' | type = ' ' Then type = '1'                              01740000
  175.                                                                         01750000
  176. item = type || name || '05'x || path || '05'x ,                         01760000
  177.             || host || '05'x || port || '05'x                           01770000
  178. 'PIPE VAR ITEM | GOPCLITM OPEN | CONSOLE'                               01780000
  179.                                                                         01790000
  180. Return                                                                  01800000
  181.                                                                         01810000
  182.                                                                         01820000
  183.                                                                         01830000
  184. /* ------------------------------------------------------------ BOOKMARK01840000
  185.  *  Present the selected bookmark or fall-back to the list of all.      01850000
  186.  */                                                                     01860000
  187. BOOKMARK:                                                               01870000
  188.                                                                         01880000
  189. /*  if bookmark was specified numeric,  just fetch it  */               01890000
  190. If Datatype(bookmark,'N') Then Do                                       01900000
  191.     i = Trunc(bookmark)                                                 01910000
  192.     'PIPE COMMAND GLOBALV SELECT GOPHER GET BOOKMARK.' || i             01920000
  193.     If bookmark.i ^= "" Then Do                                         01930000
  194.         'PIPE VAR BOOKMARK.' || i '| GOPCLITM OPEN | CONSOLE'           01940000
  195.         Return                                                          01950000
  196.         End  /*  If  ..  Do  */                                         01960000
  197.     End  /*  If  ..  Do  */                                             01970000
  198.                                                                         01980000
  199.                                                                         01990000
  200.                                                                         02000000
  201. /* ------------------------------------------------------------ BOOKLIST02010000
  202.  *  Present a menu of all of the user's bookmarks.                      02020000
  203.  */                                                                     02030000
  204. BOOKLIST:                                                               02040000
  205.                                                                         02050000
  206. If name = "" Then Do                                                    02060000
  207.     /*  extract personal name from NAMES file  */                       02070000
  208.     Parse Value Diag(08,'QUERY USERID') With user . host . '15'x .      02080000
  209.     'PIPE COMMAND NAMEFIND :USERID' user ':NODE' host ,                 02090000
  210.         ':NAME | VAR PERSONAL'                                          02100000
  211.     If rc = 0 & personal ^= "" Then                                     02110000
  212.         /*  make a title line for bookmark list  */                     02120000
  213.         'PIPE COMMAND XMITMSG 40 PERSONAL' ,                            02130000
  214.             '(APPLID GOP CALLER CLI NOHEADER | VAR NAME'                02140000
  215.     End  /*  If  ..  Do  */                                             02150000
  216.                                                                         02160000
  217. /*  extract bookmarks from GlobalVs  */                                 02170000
  218. 'PIPE COMMAND GLOBALV SELECT GOPHER LIST' ,                             02180000
  219.         '| LOCATE 1-10 / BOOKMARK./ | SPEC /=/ 1 2-* NEXT | VARLOAD'    02190000
  220. If ^Datatype(bookmark.0,'N') Then bookmark.0 = 0                        02200000
  221.                              Else bookmark.0 = Trunc(bookmark.0)        02210000
  222.                                                                         02220000
  223. 'PIPE STEM BOOKMARK. | GOPCLIMB' name '| CONSOLE'                       02230000
  224. If rc ^= 0 Then Return                                                  02240000
  225.                                                                         02250000
  226. 'GLOBALV SELECT GOPHER GET COMMAND'                                     02260000
  227. Parse Upper Var command verb .                                          02270000
  228. If Abbrev("QUIT",verb,1) Then Return                                    02280000
  229.                                                                         02290000
  230. /*  remove any blanked (deleted) bookmarks from the stem  */            02300000
  231. j = 0                                                                   02310000
  232. 'GLOBALV SELECT GOPHER GET BOOKMARK.0'                                  02320000
  233. Do i = 1 to bookmark.0                                                  02330000
  234.     'GLOBALV SELECT GOPHER GET BOOKMARK.' || i                          02340000
  235.     If  Symbol("BOOKMARK." || i) = "LIT"    | ,                         02350000
  236.                       bookmark.i = ""       | ,                         02360000
  237.                  Left(bookmark.i,1) = 'i'   Then    Iterate             02370000
  238.     j = j + 1                                                           02380000
  239.     bookmark.j = bookmark.i                                             02390000
  240.     'GLOBALV SELECT GOPHER PUTP BOOKMARK.' || j                         02400000
  241.     End                                                                 02410000
  242. bookmark.0 = j                                                          02420000
  243. 'GLOBALV SELECT GOPHER PUTP BOOKMARK.0'                                 02430000
  244.                                                                         02440000
  245. Return                                                                  02450000
  246.                                                                         02460000
  247.